/**
 * @fileOverview Main gadget file
 * 
 * @author Adam Hořčica horcicaa@gmail.com
 * @url $HeadURL: http://ahs-gadgets.googlecode.com/svn/tags/bb-counters/1.0/src/main.js $
 * @revision $Id: main.js 47 2008-02-09 20:30:13Z horcicaa $
 */

/**
 * Initialize of Gadget
 */ 
_IG_RegisterOnloadHandler(function()
{
  var prefs = new _IG_Prefs();
  var items = $("items");

  HightController.init(prefs, items);
  StateController.init(prefs);

  var counters = prefs.getArray("counters");
  
  /** 
   * Create Counter widget from list
   * @ignore 
   */
  function initCounters(list)
  {
    for(var i = 0; i < counters.length; i++)
    {
      var id = _trim(counters[i]);
      (new CounterController(id, items, i));
    }
  }
  
  if(counters.length > 0)
  {
    initCounters(counters);
  }
  else
  {
    items.innerHTML = "<em class='info'>__MSG_no_counters_text__</em>";
  }
  
  HightController.resize();
  try{
    _IG_Analytics("UA-1556984-4", "/bb-counters/");
  } catch(e){}
});
